package com.example.systemwork.entity;

import com.example.systemwork.common.entity.LogicEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
public class Item extends LogicEntity {
    @Column
    private String itemName;
    @Column
    private Double price;
    @ManyToOne(fetch = FetchType.LAZY)
    @JsonIgnoreProperties(value = {"items","shop"})
    private Business business;

    @OneToMany(mappedBy = "item",
            fetch = FetchType.LAZY,
            cascade = CascadeType.ALL)
    @JsonIgnoreProperties(value = {"item","torder"})
    private Set<LineItem> lineItems;

    @OneToMany(mappedBy = "shop",
            fetch = FetchType.LAZY,
            cascade = CascadeType.ALL)
    @JsonIgnoreProperties(value = {"shop","item"})
    private Set<ShopItem> shopItems;
}
